Show event sources and receivers.

Andrew Cantino 11 lat temu
rodzic
commit
55b8f8064c
1 zmienionych plików z 50 dodań i 28 usunięć
  1. 50 28
      app/views/agents/show.html.erb

+ 50 - 28
app/views/agents/show.html.erb

@@ -13,7 +13,7 @@
13 13
           <% end %>
14 14
           <li><a href="#logs" data-toggle="tab" data-agent-id="<%= @agent.id %>"><i class='icon-list-alt'></i> Logs</a></li>
15 15
 
16
-          <% if @agent.events.count > 0 %>
16
+          <% if @agent.can_create_events? && @agent.events.count > 0 %>
17 17
             <li><%= link_to '<i class="icon-random"></i> Events'.html_safe, events_path(:agent => @agent.to_param) %></li>
18 18
           <% end %>
19 19
           <li><%= link_to '<i class="icon-chevron-left"></i> Back'.html_safe, agents_path %></li>
@@ -29,7 +29,7 @@
29 29
                   </li>
30 30
                 <% end %>
31 31
 
32
-                <% if @agent.events.count > 0 %>
32
+                <% if @agent.can_create_events? && @agent.events.count > 0 %>
33 33
                   <li>
34 34
                     <%= link_to '<i class="icon-trash"></i> Delete all events'.html_safe, remove_events_agent_path(@agent), method: :delete, data: {confirm: 'Are you sure you want to delete ALL events for this Agent?'}, :tabindex => "-1" %>
35 35
                   </li>
@@ -70,38 +70,60 @@
70 70
               <%= @agent.short_type.titleize %>
71 71
             </p>
72 72
 
73
-            <p>
74
-              <b>Schedule:</b>
75
-              <%= (@agent.schedule || "n/a").humanize.titleize %>
76
-            </p>
73
+            <% if @agent.can_be_scheduled? %>
74
+              <p>
75
+                <b>Schedule:</b>
76
+                <%= (@agent.schedule || "n/a").humanize.titleize %>
77
+              </p>
77 78
 
78
-            <p>
79
-              <b>Last checked:</b>
80
-              <% if @agent.cannot_be_scheduled? %>
81
-                N/A
82
-              <% else %>
79
+              <p>
80
+                <b>Last checked:</b>
83 81
                 <%= @agent.last_check_at ? time_ago_in_words(@agent.last_check_at) + " ago" : "never" %>
84
-              <% end %>
85
-            </p>
82
+              </p>
83
+            <% end %>
86 84
 
87
-            <p>
88
-              <b>Last event created:</b>
89
-              <%= @agent.last_event_at ? time_ago_in_words(@agent.last_event_at) + " ago" : "never" %>
90
-            </p>
85
+            <% if @agent.can_create_events? %>
86
+              <p>
87
+                <b>Last event created:</b>
88
+                <%= @agent.last_event_at ? time_ago_in_words(@agent.last_event_at) + " ago" : "never" %>
89
+              </p>
90
+            <% end %>
91 91
 
92
-            <p>
93
-              <b>Last received event:</b>
94
-              <% if @agent.cannot_receive_events? %>
95
-                N/A
96
-              <% else %>
92
+            <% if @agent.can_receive_events? %>
93
+              <p>
94
+                <b>Last received event:</b>
97 95
                 <%= @agent.last_receive_at ? time_ago_in_words(@agent.last_receive_at) + " ago" : "never" %>
98
-              <% end %>
99
-            </p>
96
+              </p>
97
+            <% end %>
100 98
 
101
-            <p>
102
-              <b>Event count:</b>
103
-              <%= link_to @agent.events.count, events_path(:agent => @agent.to_param) %>
104
-            </p>
99
+            <% if @agent.can_create_events? %>
100
+              <p>
101
+                <b>Events created:</b>
102
+                <%= link_to @agent.events.count, events_path(:agent => @agent.to_param) %>
103
+              </p>
104
+            <% end %>
105
+
106
+            <% if @agent.can_receive_events? %>
107
+              <p>
108
+                <b>Event sources:</b>
109
+                <% if @agent.sources.length %>
110
+                  <%= @agent.sources.map { |source_agent| link_to(source_agent.name, agent_path(source_agent)) }.to_sentence.html_safe %>
111
+                <% else %>
112
+                  None
113
+                <% end %>
114
+              </p>
115
+            <% end %>
116
+
117
+            <% if @agent.can_create_events? %>
118
+              <p>
119
+                <b>Event receivers:</b>
120
+                <% if @agent.receivers.length %>
121
+                  <%= @agent.receivers.map { |receiver_agent| link_to(receiver_agent.name, agent_path(receiver_agent)) }.to_sentence.html_safe %>
122
+                <% else %>
123
+                  None
124
+                <% end %>
125
+              </p>
126
+            <% end %>
105 127
 
106 128
             <p>
107 129
               <b>Working:</b>